BEGIN{
  tl=ARGV[2]; delete ARGV[2];
  hl=ARGV[3]; delete ARGV[3];
  ARGC=2;
  out=1;
  if(tl==0&&hl==0){first=1};
}
# note: the order of lines is crucial!!!
$1=="start_paradump"{out=0}
this_sample&&$1=="end_ppos_params"{out=0}
out{print}
$1=="end_paradump"{out=1}
this_sample&&$1=="start_ppos_params"{out=1}
this_sample&&$1=="end_ppos_params"{this_sample=0}
this_sample&&$1=="start_dfit_params"{dwfac=1}
dwfac{dw=dw$0"\n"}
this_sample&&$1=="end_dfit_params"{dwfac=0}
$1=="_newsample_"&&((tl==$2&&hl==$3)||first){
  first=0;
  this_sample=1;
  sub(/_newsample_ /,"");
  fitrep="fitrep "$0;
}
END{
  printf dw;
  print fitrep;
#  print fitrep > "/dev/stderr";
}
